package com.atguigu.admin.service.impl;

import com.atguigu.admin.mapper.AdminUserMapper;
import com.atguigu.admin.param.AdminUserParam;
import com.atguigu.admin.pojo.AdminUser;
import com.atguigu.admin.service.AdminUserService;
import com.atguigu.constants.UserConstants;
import com.atguigu.utils.MD5Util;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * ClassName:AdminUserServiceImpl
 * Package:com.atguigu.admin.service.impl
 * Description:
 *
 * @Author 应永豪
 * @Create 2024/4/23 10:34
 * @Version 1.0
 */
@Service
@Slf4j
public class AdminUserServiceImpl implements AdminUserService {

    @Autowired
    private AdminUserMapper adminUserMapper;
    @Override
    public AdminUser login(AdminUserParam adminUserParam) {
        QueryWrapper<AdminUser> adminUserQueryWrapper = new QueryWrapper<>();
        adminUserQueryWrapper.eq("user_account",adminUserParam.getUserAccount())
                .eq("user_password", MD5Util.encode(adminUserParam.getUserPassword()+ UserConstants.USER_SALT));

        AdminUser adminUser = adminUserMapper.selectOne(adminUserQueryWrapper);
        log.info("AdminUserServiceImpl.login业务执行完毕，结果为：{}",adminUser);
        return adminUser;
    }
}
